Skip to content

Add list_code_quality_findings tool to code_quality toolset - #3564

Merged
SamMorrowDrums merged 6 commits into
mainfrom
carogalvin-list-code-quality-findings-tool
Nov 25, 2026
Merged

SamMorrowDrums merged 6 commits into
mainfrom
carogalvin-list-code-quality-findings-tool

Conversation

@carogalvin

@carogalvin carogalvin commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a read-only list_code_quality_findings tool to the code_quality toolset. It lists a repository's code quality findings through GET /repos/{owner}/{repo}/code-quality/findings and supports the state and direction filters plus cursor pagination.

Why

Closes #3560

What changed

  • Added ListCodeQualityFindings in pkg/github/code_quality.go, modelled on list_dependabot_alerts:
    • Uses WithCursorPagination (perPage, after) and NewToolWithSchemaOptions, with ValidationInputSchema: inventory.CloneSchemaWithoutDefaults(schema).
    • Is marked ReadOnlyHint: true.
    • Uses translation keys TOOL_LIST_CODE_QUALITY_FINDINGS_*.
  • Inputs: owner and repo are required. state accepts open or dismissed and defaults to open. direction accepts asc or desc and defaults to desc. These are the only filters the endpoint supports.
  • go-github v92 has CodeQuality.ListFindings, but the tool sends a raw client.NewRequest to match GetCodeQualityFinding and to return the REST JSON unchanged to legacy clients.
  • Added ListCodeQualityFindingsInput and CodeQualityFindingsOutput (findings plus pageInfo) to pkg/github/security_outputs.go:
    • Legacy protocols get the REST findings as returned, plus pageInfo.
    • Typed-output protocols get the existing CodeQualityFindingOutput DTO.
  • Registered the tool in pkg/github/tools.go, right after GetCodeQualityFinding.
  • When the ifc_labels feature flag is on, successful results carry the ifc.LabelSecurityAlert() IFC label (private, untrusted), the same label the code scanning, Dependabot and secret scanning tools use.
  • Tests:
    • Test_ListCodeQualityFindings covers the toolsnap, schema assertions, defaults, the state and direction filters, cursor passthrough, the returned next cursor, the IFC label, 403 and 404 responses, and missing owner or repo.
    • Added the tool to the shared typed security output and compatibility tests.
  • The endpoint's Link header includes a rel="last" link with an empty before= value. pageInfo reads cursors only from rel="next" and rel="prev", so it never returns that empty cursor. A test using the real header shape covers this.
  • New toolsnap list_code_quality_findings.snap, and the README is regenerated.
  • Covered the tool in the repository-health-review bundled skill: added it to the skill's optional tools in pkg/skills/catalog/tools.go and to the skill's outstanding-risk step, next to the code scanning and Dependabot alert tools.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added
    • New tool added: list_code_quality_findings. It is in the existing code_quality toolset. There is no feature flag, and the default toolsets are unchanged.

Prompts tested (tool changes only)

I tested these against a local build over stdio, using a repository that has Code Quality enabled.

  • "List open code quality findings in monalisa/smile, 5 per page": returns 5 findings, hasNextPage: true, and a nextCursor.
  • "Get the next page of code quality findings in monalisa/smile" (passing after): returns the next 5 findings in the same order as the REST API, with both cursors.
  • "List dismissed code quality findings in monalisa/smile": returns only dismissed findings.
  • "List the oldest code quality findings in monalisa/smile" (direction: asc): returns findings in ascending order.
  • "List all open code quality findings in monalisa/smile, 100 per page": the count matches the repository's open-findings total.
  • "List code quality findings in github/github-mcp-server", a repo without Code Quality enabled: returns failed to list findings for repository 'github/github-mcp-server': ... 403 Code quality is not enabled for this repository. Please enable code quality in the repository settings.
  • state: closed: schema validation rejects it.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
    • The tool uses the same auth as get_code_quality_finding: scopes.PublicRead(scopes.Repo), which needs the repo OAuth scope for private repositories.
  • Data exposure, filtering, or token/size limits considered
    • With the ifc_labels feature flag on, results carry the ifc.LabelSecurityAlert() IFC label, like the code scanning, Dependabot and secret scanning tools. Findings include file paths and messages derived from repository code, so they are marked untrusted. They are marked private because only users with write access can view findings (docs). I confirmed on a live call that the label appears with the flag on and is absent with it off.
    • get_code_quality_finding still has no IFC label (it merged just after labels were added to the read tools). That can be fixed in a follow-up.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint: passed, 0 issues.
  • Tested locally with ./script/test: passed after merging main, including go test ./pkg/skills/catalog -run TestCatalogToolRequirementsAreRegistered -count=1. UPDATE_TOOLSNAPS=true go test ./... also passed; it added one new snapshot and changed no others.

Docs

  • Not needed
  • Updated (README / docs / examples)
    • Regenerated the README with script/generate-docs. The only change is the new tool entry.

Skills

  • Updated relevant skills or confirmed no bundled skill applies
    • Added list_code_quality_findings to the repository-health-review skill as an optional tool, next to list_code_scanning_alerts and list_dependabot_alerts. The skill's outstanding-risk step now counts open code quality findings by rule.severity.

Copilot AI added 4 commits October 23, 2026 12:01
Add a read-only tool that lists code quality findings for a repository
via GET /repos/{owner}/{repo}/code-quality/findings. It supports the
endpoint's filters: state (open or dismissed, defaulting to open),
direction (asc or desc), and cursor pagination (perPage, after).

The tool follows the list_dependabot_alerts pattern: cursor pagination
schema, defaults stripped from the validation schema, a typed output
with findings and pageInfo, and the same scopes as
get_code_quality_finding. Like get_code_quality_finding, it attaches
no IFC label.

Includes unit tests, the tool snapshot, and regenerated README docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The endpoint sorts findings by creation date only, so describe the
direction values in those terms.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Every tool must be covered by a bundled skill or explicitly exempted.
Add list_code_quality_findings as an optional tool of the
repository-health-review skill, next to the code scanning and
Dependabot alert tools, and mention it in the outstanding-risk step.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread pkg/github/code_quality.go Dismissed
}

response := struct {
Findings json.RawMessage `json:"findings"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a known potential issue, but from what I can see in other tools we have there's no perfect fix for it. It looks like the metadata wrapping this autofix is suggesting was rejected in other PRs. Notably this tool will only return findings from the default branch of the repository at this time, so any malicious instructions would have to be placed by folks with permission to write code to the repo.

Label successful results with ifc.LabelSecurityAlert() (private,
untrusted) when the ifc_labels feature flag is enabled, the same label
the code scanning, Dependabot and secret scanning tools use. Findings
embed file paths and messages derived from repository code, and without
a label, clients that enforce IFC have no classification for this data.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
return utils.NewToolResultErrorFromErr("failed to marshal findings", err), CodeQualityFindingsOutput{}, nil
}

result := utils.NewToolResultText(string(r))

@carogalvin carogalvin Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a known potential issue, but from what I can see in other tools we have there's no perfect fix for it. The suggested fix drops the findings from the text output, which breaks clients that read text instead of structured content; the same change was declined in #3719. Notably this tool will only return findings from the default branch of the repository at this time, so any malicious instructions would have to be in code that someone with write access has merged into the default branch.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Copilot is being a bit extra here. Don't worry about that.

@carogalvin
carogalvin marked this pull request as ready for review November 19, 2026 15:29
@carogalvin
carogalvin requested a review from a team as a code owner November 19, 2026 15:29
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The tool’s protocol-dependent outputs, cursor pagination, and restricted findings with feature-gated IFC metadata require broader review of interacting data-access and compatibility contracts.

No open issues 🎉

What changed in this PR

Adds list_code_quality_findings to the existing code_quality toolset, letting agents discover findings without knowing their numbers first, addressing #3560.

Changes:

  • Adds read-only listing with state and sort-direction filters, cursor pagination, and private/untrusted labels when enabled.
  • Supports legacy JSON responses and typed outputs, with behavioral, compatibility, and schema tests.
  • Documents the tool and integrates it into the repository-health-review skill.
File Description
README.md Documents the new tool and its inputs.
pkg/​skills/​catalog/​tools.go Adds the tool as an optional repository-health capability.
pkg/​skills/​catalog/​skills/​repository-health-review/​SKILL.md Includes code quality findings in risk assessment.
pkg/​github/​typed_security_outputs_test.go Tests typed output and legacy field preservation.
pkg/​github/​typed_security_compatibility_test.go Covers filters, empty results, errors, and protocol compatibility.
pkg/​github/​tools.go Registers the new tool.
pkg/​github/​security_outputs.go Defines listing input and output types.
pkg/​github/​helper_test.go Adds the mock listing endpoint.
pkg/​github/​code_quality.go Implements listing, pagination, error handling, and result labeling.
pkg/​github/​code_quality_test.go Tests tool metadata, requests, pagination, labels, and errors.
pkg/​github/​__toolsnaps__/​list_code_quality_findings.snap Records the tool’s input and output schemas.

Review effort: Balanced (adaptive)

@tjgurwara99 tjgurwara99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Still it might be ideal to get some eyes from the owners/maintainers of this repo too 😄

@SamMorrowDrums
SamMorrowDrums merged commit 7edc2dd into main Nov 25, 2026
22 checks passed
@SamMorrowDrums
SamMorrowDrums deleted the carogalvin-list-code-quality-findings-tool branch November 25, 2026 15:04
@SamMorrowDrums

Copy link
Copy Markdown
Collaborator

Merged, but just did a release, so it might be a few days before it hits remote server 🙏

cursor Bot pushed a commit to nanami7777777/github-mcp-server that referenced this pull request Nov 26, 2026
Bring in 7edc2dd (list_code_quality_findings, github#3564). The README catalog addition does not overlap the go install section. Go lines stay at 1.27.4.
Co-authored-by: ango <nanami7777777@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add list_code_quality_findings tool to the code_quality toolset

7 participants